home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / make / icmake-6.000 / icmake-6 / icmake / rss / xstrdup.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-08  |  747 b   |  36 lines

  1. /*
  2. \funcref{xstrdup}{char $*$xstrdup (\params)}
  3.     {
  4.         {char} {*s} {string to duplicate}
  5.     }
  6.     {pointer to duplicated string}
  7.     {error()}
  8.     {xrealloc()}
  9.     {xstrdup.c}
  10.     {
  11.         {\em xstrdup()} behaves like {\em strdup()}, except that when memory is
  12.         exhausted (therefore, when the string cannot be duplicated) function
  13.         {\em error()} is called to terminate the program.
  14.  
  15.         The string to duplicate, {\em s}, may be {\em NULL}. In this case a
  16.         duplicate of a zero-length string is returned.
  17.     }
  18. */
  19.  
  20. #include "icrssdef.h"
  21.  
  22. char *xstrdup (s)
  23. char *s;
  24. {
  25.     register char
  26.         *ret;
  27.  
  28.     if (! s)
  29.         s = "";
  30.  
  31.     if (! (ret = strdup (s)) )
  32.         error ("out of memory");
  33.  
  34.     return (ret);
  35. }
  36.